home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / srefv12i.zip / htaccfg.cmd < prev    next >
OS/2 REXX Batch file  |  1997-03-07  |  26KB  |  696 lines

  1. /*  */
  2. htaccfg:
  3.  
  4. CHECKIT=0   /* Change this to 0 if you want to enable REMOTE configuration by SUPERUSERS */
  5.  
  6. /* background color */
  7. USECOLOR='2dd52f'
  8.  
  9. /* ---------------- DO NOT MODIFY BELOW THIS LINE  ------------------ */
  10.  
  11.  
  12.  
  13. parse arg ddir,tempfile,sel,list,verb,uri,user,basedir,workdir,privset, ,
  14.                enmadd,transaction,verbose, ,
  15.               servername,host_nickname,homedir
  16.  
  17. if verb=" " then do
  18.     say " This SRE-Filter procedure is NOT meant to be run from the command line."
  19.    exit
  20. end  /* Do */
  21.  
  22. list=translate(list, ' ', '+'||'090a0d'x)  /* Whitespace, etc. */
  23. /* write results (2nd call */
  24. if pos('WRITETO=',translate(list))>0 then do
  25.    call writeres
  26.   return ' Results written '
  27. end
  28.  
  29.  
  30. who2=extract('CLIENTADDR')
  31. saddr2=extract('SERVERADDR')
  32.  
  33. select
  34.    when checkit=1 then do
  35.  
  36. /* only if user = serveraddress !!! */
  37.      if who2<>saddr2 then do
  38.  
  39.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  40.         call lineout tempfile, "<html><head><title>SREFILTER ERROR </title>"
  41.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  42.  
  43.  
  44.         call lineout tempfile,' <strong> Action not allowed remotely.</strong> <pre>'
  45.         call lineout tempfile,' </body> </html> '
  46.         call lineout tempfile
  47.         'FILE ERASE TYPE text/html NAME' tempfile
  48.         return 'HTACCFG: action not allowed remotely. '
  49.      end
  50.    end
  51.    otherwise do
  52.       if wordpos('SUPERUSER',privset)=0 then do
  53.         'RESPONSE HTTP/1.0 401 Unauthorized '     /* Set HTTP response line */
  54.         'header add WWW-Authenticate: Basic Realm=<CONFIGURE>'  /* challenge */
  55.  
  56.         call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  57.         call lineout tempfile, "<html><head><title>Not authorized </title>"
  58.         call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  59.  
  60.         call lineout tempfile,' <strong> You do not have configuration rights.</strong> <pre>'
  61.         if who2=saddr2 then 
  62.                 call lineout tempfile,'<br> <Em> You may want to edit HTACCFG.CMD </em> '
  63.         call lineout tempfile,' </body> </html> '
  64.         call lineout tempfile
  65.          iia=dosdir(tempfile,'s')
  66.  
  67.         'FILE ERASE TYPE text/html NAME' tempfile
  68.         return '401 'iia' HTACCFG: not permitted to configure. '
  69.       end
  70.    end
  71. end
  72.  
  73.  
  74. htfile=' ' ;htacc=' '
  75. list=strip(list)
  76. DO UNTIL LIST=""
  77.     PARSE VAR  list a1 '&' list
  78.     parse var a1 avar '=' aval
  79.     if translate(avar)='HTFILE' then do
  80.          htfile=strip(translate(translate(packur(aval),'\','/')))
  81.          htfile=strip(htfile,'t','\')||'\'
  82.     end
  83.     if translate(avar)='ACCFILE' then
  84.          htacc=strip(translate(translate(packur(aval),'\','/')))
  85. end /* do */
  86. if left(htfile,1)='\' | pos(':',htfile)>0 then
  87.    nop
  88. else 
  89.    htfile=translate(ddir||htfile,'\','/')
  90.  
  91. if htacc=' ' then
  92.    htacc=get_value('htaccess_file')
  93.  
  94. if filespec('p',htfile)='\' then do
  95.    call lineout tempfile,' <h2> ' HTFILE ' not permitted </h2> '
  96.   call lineout tempfile,' Sorry, HTACCESS file can <strong>not</strong> be in the root'
  97.   call lineout tempfile, '</body> </html> '
  98.   call lineout tempfile
  99.   'file erase  type text/html name  ' tempfile
  100.   return 'htaccess not allowed in root '
  101. end
  102. if htfile=' '| htacc=' ' then do
  103.    call lineout tempfile,' <h2> Missing information </h2> '
  104.   call lineout tempfile,' Sorry, the directory, or the name for the HTACCESS file,'
  105.   call lineout tempfile,' was not specified.'
  106.   call lineout tempfile, '</body> </html> '
  107.   call lineout tempfile
  108.   'file erase  type text/html name  ' tempfile
  109.   return ' missing information '
  110. end /* do */
  111.  
  112.  
  113. HTFILE=STRIP(HTFILE); HTFILE=STRIP(HTFILE,'T','\')||'\'
  114. tmp1=get_htaccess(0,HTfile,HTACC,ddir,TEMPFILE,2)
  115.  
  116. parse var tmp1 gotlist ',' tmp1
  117. gotlist=strip(gotlist)
  118.  
  119. this1=htfile||htacc
  120. is1=stream(this1,'c','query exists')
  121.  
  122. vlist='GOTLIST AUTH.NAME AUTH.TYPE AUTH.USERFILE AUTH.GROUPFILE '
  123. vlist=vlist||'AUTH.INDEX REDIRECTFILE AUTH.LIMIT DIR.BUILD DIR.EXCLUDE '
  124. vlist=vlist||'DIR.INFO  DIR.DESCRIBE DIR.FORBID RX.BUILDdir RX.ENABLEPOSTPROCESS'
  125.  
  126. vlist2=' x AuthName AuthType AuthUserFile AuthGroupFile DefaultIndex RedirFile '
  127. vlist2=vlist2||' Limit BuildDir Dir.Exclude Dir.Info Dir.Describe Dir.Forbid '
  128. vlist2=vlist2||' Dir.Builder EnablePostProcess '
  129. gotlist0=gotlist
  130.  
  131. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  132. call lineout tempfile, "<html><head><title>SRE-Filter HTACCESS configurator </title>"
  133. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  134.  
  135. call lineout tempfile, "<h1> SRE-Filter: <A NAME="top"> HTACCESS Configurator </A>   </h1> <p>"
  136. call lineout tempfile,' <a href="#review"> Review current parameters & files for ' htfile '</a> ?'
  137.  
  138.  
  139. this1a=strip(this1,'t','.')
  140. foo=wordpos(translate(this1a),translate(gotlist))
  141. if foo>0 then do
  142.     gotlist=delword(gotlist,foo,1)
  143. end  /* Do */
  144.  
  145. call lineout tempfile,' <h2> For directory== ' translate(htfile) ' </h2>'
  146. call lineout tempfile,' <ul> '
  147. if is1=' ' then
  148.   call lineout tempfile,' <li> Currently, there is <strong> no</strong> HTACCESS file in: ' htfile
  149. else
  150.   call lineout tempfile,' <li> The HTACCESS file for ' htfile ' is: <strong> ' this1 '</strong>'
  151.  
  152.  
  153. if gotlist<>' ' then
  154.   call lineout tempfile,' <li> The set of HTACCESS files in the parent directories are: <strong> ' gotlist '</strong>'
  155.  
  156. call lineout tempfile,' </ul>'
  157.  
  158.  
  159. /* get "this files" parameter values (if accessible ) */
  160. if is1 =' ' then do
  161.    call lineout tempfile,' <hr width=30%> <h3> Creating: ' this1 ' </h3>  '
  162. /* initialize some variable */
  163.    auth.name=' '; auth.type=' ' ; auth.userfile=' ' ; auth.groupfile=' '
  164.    auth.index=' '; redirectfile=' '; auth.limit=' '; dir.exclude=' ';
  165.    dir.info=' ' ; dir.describe=' ' ; dir.forbid=' ' ; rx.builddir=' '
  166. end
  167. else do
  168.    tmp1=get_htaccess(0,HTfile,HTACC,ddir,TEMPFILE,3)
  169.  
  170.    do mm=1 to words(vlist)
  171.      parse var tmp1 aval ',' tmp1
  172.      avar=word(vlist,mm) ; aval=strip(aval)
  173.      call value avar,aval
  174.   end /* do */
  175.   call lineout tempfile,' <hr width=30%>  <h3> Modifying: ' this1 ' </h3>  '
  176. end
  177.  
  178. /* let user fill out form */
  179. CALL LINEOUT TEMPFILE,'<FORM ACTION="/HTACCFG" METHOD="POST">'
  180. call lineout tempfile,'<h3> Access control parameters </h3>'
  181.  
  182. ee=makeit('<b>One line comment:</b>','COMMENT',gotlist0,' ')
  183. call lineout tempfile,ee
  184.  
  185.  
  186. ee=makeit(' <p> <b>AuthName</b>: Authorization name (the REALM) ','AuthName',gotlist0,auth.name,10)
  187. call lineout tempfile,ee
  188.  
  189.  
  190. ischeck1=' ' ;IF translate(auth.type)='BASIC' then ischeck1='CHECKED'
  191. ischeck2=' ';IF translate(auth.type)='IDENT' then ischeck2='CHECKED'
  192. call lineout tempfile,' <p><b>AuthType</b>: Authorization type: '
  193. CALL LINEOUT TEMPFILE,' <INPUT TYPE=RADIO NAME="AuthType" VALUE="BASIC"' ISCHECK1 ' >BASIC ||'
  194. CALL LINEOUT TEMPFILE,'<INPUT TYPE=RADIO NAME="AuthType" VALUE="IDENT"' ISCHECK2 ' >IDENT '
  195.  
  196. ee=makeit('<b>AuthUserfile</b>: Userfile (contains usernames and passwords) ','AuthUserFile',gotlist0,auth.userfile)
  197. call lineout tempfile,ee
  198.  
  199. ee=makeit('<b>AuthGroupfile</b>: Group file (groups of users) ','AuthGroupFile',gotlist0,auth.groupfile)
  200. call lineout tempfile,ee
  201.  
  202.  
  203. if wordpos('REQUIRE',translate(auth.limit))=1 then
  204.    auth.limit=delword(auth.limit,1,1)
  205. ee=makeit('<b>Limit</b>:Allowed users list','Limit',gotlist0,auth.limit)
  206. call lineout tempfile,ee
  207.  
  208. call lineout tempfile, ' <p> <h3> Redirection, etc. parameters </h3>'
  209.  
  210. ee=makeit('<b>DefaultIndex</b>: Directory specific default documents ','DefaultIndex',gotlist0,auth.index)
  211. call lineout tempfile,ee
  212.  
  213. ee=makeit('<b>ReDirFile</b>: Redirection file ','ReDirFile',gotlist0,REDIRECTFILE)
  214. call lineout tempfile,ee
  215.  
  216.  
  217. call lineout tempfile,' <p><h3>Parameters used by dynamic directory list processor </h3>'
  218.  
  219. ischeck1=' ' ;IF dir.build=1 then ischeck1='CHECKED'
  220. ischeck2=' ';IF  dir.build=0 then ischeck2='CHECKED'
  221. call lineout tempfile,' <p> <B>BuildDir</b>:Enable dynamic directory list processor: '
  222. CALL LINEOUT TEMPFILE,' <INPUT TYPE=RADIO NAME="Builddir" VALUE="1"' ISCHECK1 ' >YES (allow) || '
  223. CALL LINEOUT TEMPFILE,'<INPUT TYPE=RADIO NAME="Builddir" VALUE="0"' ISCHECK2 ' >NO  (do not allow)'
  224.  
  225. ee=makeit('<b>Dir.Exclude</b>:Exclusion files (these files are not displayed) ', ,
  226.           'Dir.Exclude',gotlist0,dir.exclude)
  227. call lineout tempfile,ee
  228. ischeck1=' ' ;IF _diris=1 then ischeck1='CHECKED'
  229. ischeck0=' ';IF  _diris=0 then ischeck0='CHECKED'
  230. call lineout tempfile,' <br><blockquote> Reset list of exclusion files  '
  231. CALL LINEOUT TEMPFILE,'<menu> <li> <INPUT TYPE=RADIO NAME="_diris" VALUE="1" 'ischeck1' > YES (use _Dir.Exclude) '
  232. CALL LINEOUT TEMPFILE,'<li> <INPUT TYPE=RADIO NAME="_diris" VALUE="0" 'ischeck0'> NO  (use Dir.Exclude) </menu> </blockquote>'
  233.  
  234.  
  235.  
  236. ee=makeit('<b>Dir.Info</b>: Directory Info file (displayed at top of document) ', ,
  237.           'Dir.Info',gotlist0,dir.info)
  238. call lineout tempfile,ee
  239.  
  240.  
  241. ee=makeit('<b>Dir.Describe</b>:File description file (per entry descriptions) ', ,
  242.           'Dir.Describe',gotlist0,dir.describe)
  243. call lineout tempfile,ee
  244.  
  245. ee=makeit('<b>Dir.Builder:</b> Name of dynamic directory list processor ', ,
  246.           'Dir.Builder',gotlist0,rx.builddir)
  247. call lineout tempfile,ee
  248.  
  249. ischeck1=' ' ;IF dir.forbid=1 then ischeck1='CHECKED'
  250. ischeck2=' ';IF  dir.forbid=0 then ischeck2='CHECKED'
  251. call lineout tempfile,' <p><b>Dir.Forbid</b>: Prevent directory list processor from displaying directory: <menu>'
  252. CALL LINEOUT TEMPFILE,' <li> <INPUT TYPE=RADIO NAME="Dir.Forbid" VALUE="1"' ISCHECK1 ' >YES (do NOT allow display) '
  253. CALL LINEOUT TEMPFILE,'<li> <INPUT TYPE=RADIO NAME="Dir.Forbid" VALUE="0"' ISCHECK2 ' >NO  (allow display) </menu>'
  254.  
  255. ischeck=' '; if rx.enablepostprocess=' ' then ischeck='CHECKED'
  256. ischeck0=' ' ;IF rx.enablepostprocess=0 then ischeck0='CHECKED'
  257. ischeck1=' ' ;IF rx.enablepostprocess=1 then ischeck1='CHECKED'
  258. ischeck2=' ' ;IF rx.enablepostprocess=2 then ischeck2='CHECKED'
  259. call lineout tempfile,'<br> <b>EnablePostProcessor</b>: Post processing option: <menu>'
  260. CALL LINEOUT TEMPFILE,' <li><INPUT TYPE=RADIO NAME="EnablePostProcess" VALUE="0"' ISCHECK0 ' >Disable Post Processing ' 
  261. CALL LINEOUT TEMPFILE,' <li><INPUT TYPE=RADIO NAME="EnablePostProcess" VALUE=" "' ISCHECK ' >Enable for all files'
  262. CALL LINEOUT TEMPFILE,' <li><INPUT TYPE=RADIO NAME="EnablePostProcess" VALUE="1"' ISCHECK1 ' >Enable for all files .*HTM* extensions'
  263. CALL LINEOUT TEMPFILE,' <li><INPUT TYPE=RADIO NAME="EnablePostProcess" VALUE="2"' ISCHECK2 ' >Enable for ".SHTML" files only'
  264.  
  265. call lineout tempfile,'</menu>'
  266.  
  267.  
  268. call lineout tempfile,' <p>  <INPUT TYPE="reset" VALUE="reset"> <br>'
  269.  
  270. if is1=' ' then
  271.    call lineout tempfile,'  <INPUT TYPE="submit" VALUE="Create 'this1'"> '
  272. else do
  273.    call lineout tempfile,'<INPUT TYPE="submit" VALUE="Modify 'this1'"> '
  274.   call lineout tempfile,' <br> <Em> --- Caution: the old copy of ' this1 ' will be deleted! </em> '
  275. end
  276.  
  277.  
  278. call lineout tempfile,'<INPUT TYPE="hidden" name="WRITETO" VALUE="'this1'">'
  279. CALL LINEOUT TEMPFILE,'</FORM>'
  280.  
  281.  
  282. /* ------ TIPS AND HINTS SETCION */
  283.  
  284. call lineout tempfile,' <hr> <P> <HR> <a name="review"> <h3> Review: Parameters and Files </h3> </a>'
  285.  
  286. call lineout tempfile," Some notes on SRE-Filter's use of HTACCESS files "
  287. call lineout tempfile,'<br> For the most part, SRE-Filter emulates GOHTTP. '
  288. call lineout tempfile,' The following lists some potential differences: '
  289. call lineout tempfile,' <ul> <li> BASIC authorization uses only the "uppermost" HTACCESS file (rather then all of them)'
  290. call lineout tempfile,'<li> EnablePostProcess is ignored for non-file transfers (that is, it is ignored when server side processing are recieved)'
  291. call lineout tempfile,' <li>Dir.Builder works -- we recommend the "SHOWDIR" variant (see SHOWDIR.DOC for details) '
  292. call lineout tempfile,'<li>To invoke the Dir.Builder "dynamic directory list processsor", put !SHOWDIR at the end of the DefaultIndex list '
  293. call lineout tempfile,' <li> IDENT is a bit flaky (it works reasonably well if you * the portion before the @ )'
  294. call lineout tempfile,'</ul>'
  295. /* parameters from own and parent htaccess files */
  296.          tmp1=get_htaccess(0,HTfile,HTACC,ddir,TEMPFILE,2)
  297.  
  298. do mm=1 to words(vlist)
  299.    parse var tmp1 aval ',' tmp1
  300.    avar=word(vlist,mm) ; aval=strip(aval)
  301.    call value avar,aval
  302. end /* do */
  303. call lineout tempfile,' <hr width=30%> <h3> Effective parameters values for ' htfile ' </h3>  '
  304. call lineout tempfile,' These may include parameters set by HTACCESS files in parent directories <br>'
  305. if gotlist0=' ' then do
  306.    call lineout tempfile,' <BLOCKQUOTE> <strong> No HTACCESS parameters! </strong> </BLOCKQUOTE>'
  307. end  /* Do */
  308. else do
  309.   call lineout tempfile,'<dl>'
  310.   do mm=2 to words(vlist)  /* dont show gotlist */
  311.      avar=word(vlist,mm) ; avar2=word(vlist2,mm)
  312.      aval=value(avar)
  313.      call lineout tempfile,' <dt> <var> ' avar2 ' </var> <dd> ' aval
  314.   end /* do */
  315.   call lineout tempfile,'</dl> '
  316. end
  317.  
  318. /* ----- USER FILE */
  319. call lineout tempfile,' <HR WIDTH=30%> <H3> User file </h3>'
  320. call lineout tempfile,' Username/password file should have entries with the following syntax:<br>'
  321. call lineout tempfile,' <blockquote> USERNAME:PASSWORD </blockquote>'
  322. call lineout tempfile,' For example: <menu> <li> John:final1 <li> Sam:invidious <li> ; comment <li> wonder:womack </menu>'
  323. call lineout tempfile,' <h3> User file for: ' htfile' </h3>'
  324. if  auth.userfile=' ' then do
  325.  call lineout tempfile,' <blockquote><strong> No user file selected </strong> </blockquote>'
  326. end
  327. else do
  328.    call lineout tempfile,' Current user file is: <strong> ' auth.userfile '</strong> <p> '
  329.    foo=get_lines(auth.userfile)
  330.  
  331.    if foo>0  then do
  332.       call lineout tempfile,' Contents of ' auth.userfile ' <code> <ul>'
  333.  
  334.       do mm=1 to foo
  335.          alin=strip(somelines.mm)
  336.          if alin=' ' then iterate
  337.          if abbrev(alin,';')=1 then
  338.                 call lineout tempfile, '<li> <em>'alin ' </em> '
  339.          else
  340.                 call lineout tempfile, '<li> 'alin  
  341.       end /* do */
  342.       call lineout tempfile,'</ul>  </code>'
  343.     end
  344.     else do
  345.         call lineout tempfile,' <blockquote>  File does not exist: <strong> 'auth.userfile '</strong> </blockquote>'
  346.     end
  347. end  /* Do */
  348.  
  349.  
  350. /* ----- groups FILE */
  351. call lineout tempfile,' <HR WIDTH=30%> <H3> Groups file </h3>'
  352. call lineout tempfile,' The user Groups file should have entries with the following syntax:<br>'
  353. call lineout tempfile,' <blockquote> GROUPNAME: user1 user2 use33r@xx.yy.zz </blockquote>'
  354. call lineout tempfile,' For example: <menu> '
  355. call lineout tempfile,' <li> Detroit: phil george '
  356. call lineout tempfile,' <li> Boston:  joe *@dept1.school.edu '
  357. call lineout tempfile,' <em>  ... (note the use of the <strong>IDENT</strong> style name, and the * wildcard)</em>'
  358. call lineout tempfile,' <li> ; comment <li> Miami:  Cheryl Ruby Carlos </menu>'
  359. call lineout tempfile,' <h3> Groups file for: ' htfile ' </h3>'
  360. if  auth.groupfile=' ' then do
  361.  call lineout tempfile,' <blockquote><strong> No group file selected </strong> </blockquote>'
  362. end
  363. else do
  364.    call lineout tempfile,' Current group file is: <strong> ' auth.groupfile '</strong> <p> '
  365.    foo=get_lines(auth.groupfile)
  366.  
  367.    if foo>0  then do
  368.       call lineout tempfile,' Contents of ' auth.groupfile ' <code> <ul>'
  369.  
  370.       do mm=1 to foo
  371.          alin=strip(somelines.mm)
  372.          if alin=' ' then iterate
  373.          if abbrev(alin,';')=1 then
  374.                 call lineout tempfile, '<li> <em>'alin ' </em> '
  375.          else
  376.                 call lineout tempfile, '<li> 'alin  
  377.       end /* do */
  378.       call lineout tempfile,'</ul>  </code>'
  379.     end
  380.     else do
  381.         call lineout tempfile,' <blockquote>  File does not exist: <strong> 'auth.groupfile '</strong> </blockquote>'
  382.     end
  383. end  /* Do */
  384.  
  385. /* ----- redirectFILE */
  386. call lineout tempfile,' <HR WIDTH=30%> <H3> Redirection file </h3>'
  387. call lineout tempfile,' The Redirection file should have entries with the following syntax:<br>'
  388. call lineout tempfile,' <blockquote> old_url  : new_url  NOTIFY </blockquote>'
  389. call lineout tempfile, 'Where NOTIFY is optional (if present, redirection will NOT occur; instead, the client recieves a short notification) <p> '
  390. call lineout tempfile,' For example: <menu> '
  391. call lineout tempfile,' <li> zoo/sched.htm : http://www.newzoo.org/index.htm '
  392. call lineout tempfile,' <li> store/toys/*:  http://toys.newstore.com/inventory/*  NOTIFY '
  393. call lineout tempfile,' <em> ... (note the use of the * wildcard) </em> '
  394. call lineout tempfile,' <li> !CASE SENSITIVE  <em> ... (following entries are case sensitive) </em> '
  395. call lineout tempfile,' <li> candy/VANILLA.HTM :  /icecream/vanilla.htm  <EM> ... ( no http:// in the new_url implies redirect to same site) </em> '
  396. call lineout tempfile,'</menu> '
  397. call lineout tempfile,' <h3> Redirection file  for: ' htfile '</h3>'
  398. if  redirectfile=' ' then do
  399.  call lineout tempfile,' <blockquote><strong> No redirection file selected </strong> </blockquote>'
  400. end
  401. else do
  402.    call lineout tempfile,' Current  redirection file is: <strong> ' redirectfile '</strong> <p> '
  403.    foo=get_lines(redirectfile)
  404.  
  405.    if foo>0  then do
  406.       call lineout tempfile,' Contents of ' redirectfile ' <code> <ul>'
  407.  
  408.       do mm=1 to foo
  409.          alin=strip(somelines.mm)
  410.          if alin=' ' then iterate
  411.          if abbrev(alin,'!')=1 then
  412.                 call lineout tempfile, '<li> <em>'alin ' </em> '
  413.          else
  414.                 call lineout tempfile, '<li> 'alin  
  415.       end /* do */
  416.       call lineout tempfile,'</ul>  </code>'
  417.     end
  418.     else do
  419.         call lineout tempfile,' <blockquote>  File does not exist: <strong> 'redirectfile '</strong> </blockquote>'
  420.     end
  421. end  /* Do */
  422.  
  423.  
  424.  
  425.  
  426. call lineout tempfile,' </body> </html> '
  427. call lineout tempfile
  428.  
  429. 'file erase  type text/html name  ' tempfile
  430.  
  431. return 'Changes made, now submitting '
  432.  
  433.  
  434. /* do mm=1 to words(vlist)
  435.    parse var tmp1 aval ',' tmp1
  436.    avar=word(vlist,mm) ; aval=strip(aval) ; avar2=word(vlist2,mm)
  437.    if mm=1 then iterate 
  438.    call lineout tempfile,' <dt> <var> ' avar2 ' </var> <dd> ' aval
  439. end
  440. call lineout tempfile,' </dl> <p> '
  441. */
  442.  
  443.  
  444. makeit:procedure
  445. parse arg message,avar,gotlist0,aval,nshow
  446. if nshow=' 'then nshow=28
  447. if gotlist0=' ' then 
  448.   t1=' ' 
  449. else 
  450.   t1=aval
  451. rr=' <p> '|| message|| ':'
  452. rr=rr||' <INPUT TYPE="text" NAME="'||avar||'"  VALUE="'||t1||'"  SIZE='nshow' MAXLENGTH=85> '
  453. return rr
  454.  
  455.  
  456.  
  457.  
  458.  
  459. /* ----------- */                                                        
  460. /* get environment value, possibly host specific */                      
  461. /* ------------ */                                                       
  462. get_value: procedure expose enmadd host_nickname usecolor
  463. parse arg vname,hname0
  464. if hname0=0 then 
  465.         hname=' '
  466. else                                                    
  467.     hname=strip(host_nickname)                          
  468.  
  469. vname=strip(vname) ;
  470. if hname<>' ' then do                                                    
  471.    aval=value(enmadd||vname||'.'||hname,,'os2environment')               
  472.    if aval<>' ' Then                                                     
  473.         return aval                                                      
  474. end                                                                      
  475. aval=value(enmadd||vname,,'os2environment')                              
  476. return aval                   
  477.  
  478.  
  479. /* write results routine */
  480. writeres:
  481. list0=list
  482. do until list=""
  483.     parse var list a1 '&' list
  484.     parse upper var a1 avar '=' aval
  485.     if avar='WRITETO' then do
  486.        htout=strip(packur(aval))
  487.        leave
  488.     end  /* Do */
  489. end /* do */
  490. foo=sysfiledelete(htout)
  491. foo=lineout(htout,,1)
  492. _diris=0
  493. if pos('_DIRIS=1',upper(list0))>0 then _diris=1
  494. list=list0
  495. do until list=""
  496.     parse var list a1 '&' list
  497.     parse var a1 avar '=' aval
  498.     avar=strip(packur(avar));
  499.     aval=strip(packur(aval));
  500.  
  501.     if translate(avar)='_DIRIS' then iterate
  502.     if translate(avar)='WRITETO' then iterate
  503.     if translate(avar)='LIMIT' then aval=' require '||aval
  504.     if translate(avar)='COMMENT' then avar='; ' 
  505.     if translate(avar)='DIR.EXCLUDE' & _diris=1 then
  506.         avar='_'||avar
  507.     if aval \=' ' then
  508.         call lineout htout,avar ':' aval
  509. end
  510. call lineout htout
  511.  
  512. call lineout tempfile, '<!doctype html public "-//IETF//DTD HTML 3.0//EN">'
  513. call lineout tempfile, "<html><head><title>SRE-Filter HTACCESS configurator </title>"
  514. call lineout tempfile, '</head><body  bgcolor="#'||usecolor||'"> '
  515.  
  516. call lineout tempfile, "<h1> SRE-Filter: <A NAME="top"> HTACCESS Configurator </A>   </h1> <p>"
  517. call lineout tempfile,' Results were written to ' htout
  518.  
  519. call lineout tempfile, '</body> </html> '
  520. call lineout tempfile
  521. 'file erase  type text/html name  ' tempfile
  522.  
  523. return 0
  524.  
  525.  
  526. /* ----------------------------------------------------------------------- */
  527. /* get_HTACCESS --- a modification of Don Meyer's CHECKAUTH & other stuff:
  528.  
  529. This will CHECK all the accessfilenames in the tree underneath
  530. file for access privileges, etc.  
  531.  
  532. For details on how to set up an accessfile, see
  533.      http://w3.ag.uiuc.edu/DLM/GOHTTP/Auth.Guide.html
  534.  
  535.  
  536. ENABLEPOSTPROCESS (use the post_filter stuff), and _DIR.BUILDER
  537.  
  538.  
  539. When dodirs=2, return ALL parameters (used by htaccess configurator)
  540. Dodirs=3, just the "own directory" (if it exists)
  541.  
  542.  
  543. */
  544.  
  545. /* ----------------------------------------------------------------------- */
  546. get_htaccess:procedure expose _diris
  547.  
  548.   parse arg sel,file,accessfilename,dir,TEMPFILE,dodirs
  549.  
  550.   file = translate( file, '/', '\')
  551.  
  552.   dir.exclude=' '
  553.   PathTo = ''
  554.   rest = file
  555.   retCode = 0
  556.   gotlist=' '
  557.   set=' '
  558.  
  559. /* initialize some variable */
  560. auth.name=' '; auth.type=' ' ; auth.userfile=' ' ; auth.groupfile=' '
  561. auth.index=' '; redirectfile=' '; auth.limit=' '; dir.exclude=' ';
  562. dir.info=' ' ; dir.describe=' ' ; dir.forbid=' ';rx.builddir=' '
  563. _diris=0
  564. rx.enablepostprocess=' '
  565. dir.build=0 ; rx.builddir=' '
  566.  
  567.  
  568.   owndir=filespec('d',file)||filespec('p',file)
  569.   owndir=translate(translate(owndir,'/','\'))
  570.   owndir=strip(owndir,'t','/')
  571.  
  572. /* find htaccess files;
  573.    and if found, extract the parameters, starting at base of directory tree
  574.    (thus, own htaccess file is favored */
  575.  
  576.   do while (rest \= '')
  577.     restdoggy=right(rest,1)
  578.     parse var rest _dir'/'rest
  579.     if (right( _dir,1) == ':') then PathTo = _dir
  580.     else PathTo = PathTo'/'_dir
  581.  
  582.     if dodirs==3 then do;
  583.           if translate(pathto) \= owndir then do
  584.                 iterate
  585.           end
  586.     end
  587.  
  588.     goofy=rest ; if goofy=' ' & restdoggy='/' then goofy='/'
  589.     if (left(PathTo,3) == '///') then 
  590.            PathTo = substr(PathTo,2)
  591.     else if (goofy \= '')  & (right( _dir,1) \= ':') then do
  592.          geek1=pathto'/'accessfilename
  593.          ACLfile = stream(geek1, 'c', 'query exists')
  594.  
  595.  
  596.       if (ACLfile \= '') then do /* if not, climb up the tree */
  597.          gotlist=gotlist' 'aclfile
  598.          Auth.GroupFile = ' '
  599.          Auth.Limit = ' '
  600.          rc = stream( ACLfile, 'c', 'OPEN READ')
  601.          line = linein( ACLfile, 1)
  602.          do while (line \= '')
  603.             do while( pos(left(line,1), "2009"x) > 0); line = substr(line, 2); end
  604.             if ( pos(left(line,1), "#") > 0) then line = substr(line, 2)
  605.             if ( left(line,1) == ';') then line = ';COMMENT'
  606.  
  607.             parse var line key ':' val
  608.             val = strip(val)
  609.             key = translate(key)
  610.             if (key = 'AUTHUSERFILE') | (key = 'AUTHGROUPFILE') | (key = 'REDIRLIST') then do
  611.                if (pos(':', val ) == 0) then do
  612.                   val = translate(val, '\', '/')
  613.                   if (left(val,1) == '\') then val = substr( val, 2)
  614.                   val = dir || val
  615.                end
  616.             end
  617.             select
  618.                when (key = 'AUTHNAME') then Auth.Name = val
  619.                when (key = 'AUTHTYPE') then Auth.Type = translate( strip(val))
  620.                when (key = 'AUTHUSERFILE') then Auth.UserFile = val
  621.                when (key = 'AUTHGROUPFILE') then Auth.GroupFile = val
  622.                when (key = 'DEFAULTINDEX') then Auth.Index = val
  623.                when (key = 'REDIRLIST') then RedirectFile = val
  624.                when (key = 'REDIRFILE') then RedirectFile = val  /* bug? in original code */
  625.                when (key = 'LIMIT') then    Auth.Limit = val
  626.                when (key = 'BUILDDIR') then Dir.Build = (val \= '0')
  627.                when (key = 'DIR.EXCLUDE') then Dir.Exclude = Dir.Exclude val
  628.                when (key = '_DIR.EXCLUDE') then do
  629.                       Dir.Exclude = val
  630.                       _diris=1
  631.                end  /* Do */
  632.                when (key = 'DIR.INFO') then Dir.Info = val
  633.                when (key = 'DIR.DESCRIBE') then Dir.Describe = val
  634.                when (key = 'DIR.FORBID') then Dir.Forbid = (val \= '0')
  635.                when (key = 'DIR.BUILDER') then Rx.BuildDir = val
  636.                when (key = 'ENABLEPOSTPROCESS') then do
  637.                      v = left(strip(val),1)
  638.                      if (pos(v, '012') > 0) then Rx.EnablePostProcess = v
  639.                   end
  640.                otherwise 
  641.             end
  642.  
  643.             line = linein( ACLfile)
  644.          end
  645.          rc = stream( ACLfile, 'c', 'close')
  646.  
  647.        end                /* this aclfile */
  648.     end          /* goofy */
  649.   end                       /* climbing up directory tree */
  650.  
  651.     bigone=gotlist', 'auth.name', 'auth.type', 'auth.userfile', 'auth.groupfile
  652.     bigone=bigone', 'auth.index', 'redirectfile', 'auth.limit', 'dir.build
  653.     bigone=bigone', 'dir.exclude', 'dir.info', 'dir.describe', 'dir.forbid', 'rx.builddir
  654.     bigone=bigone', 'rx.enablepostprocess
  655.   return bigone
  656.  
  657.     
  658.  
  659.  
  660.  
  661. /* get file line by line . Return in somelines. variable */
  662.  
  663. get_lines:procedure expose somelines.
  664.  
  665. parse arg afile
  666. crlf='0d0a'x
  667.  
  668. mm=0
  669.  
  670. foo=stream(afile,'c','query exists')
  671. if foo=' ' then do
  672.    somelines.0=0
  673.    return 0
  674. end
  675.  
  676. foo=charin(afile,1,chars(afile))
  677. foo=strip(foo,'t','1a'x)
  678. a=stream(afile,'c','close')
  679.  
  680. do until foo=''
  681.    parse var foo  aline (crlf) foo
  682.    mm=mm+1
  683.    somelines.mm=aline
  684. end
  685. somelines.0=mm
  686.  
  687. return mm
  688.  
  689.  
  690. end /* do */
  691.  
  692.  
  693.  
  694.  
  695.  
  696.